<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:c="http://java.sun.com/jsp/jstl/core">

    <body>

        <ui:composition template="./../template.xhtml">
            <ui:define name="meta">

                <c:if test="${user == null}">
                    <meta http-equiv="refresh" content="0; URL=#{facesContext.externalContext.requestContextPath}/faces/login.xhtml" />
                </c:if>
            </ui:define>
            <ui:define name="title">
                My Participate Event
            </ui:define>

            <ui:define name="content">
                <h:form>
                    <h:outputText escape="false" value="(You don't send request participate)" rendered="#{registrationController.itemsRegUser.rowCount == 0}"/>
                    <p:dataTable value="#{registrationController.itemsRegUser}" var="item" rendered="#{registrationController.itemsRegUser.rowCount > 0}"
                                 paginator="true" rows="10"
                                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                                 rowsPerPageTemplate="5,10,15"
                                 style="font-size: 12px;"
                                 >
                        <p:column style="width: 120px;" sortBy="#{item.eventInfo.eventName}" filterBy="#{item.eventInfo.eventName}">
                            <f:facet name="header">
                                <h:outputText escape="false" value="Event&lt;br/&gt;Name"/>
                            </f:facet>
                            <h:outputText value="#{item.eventInfo.eventName}" />
                        </p:column>
                        <p:column style="width: 90px;">
                            <f:facet name="header">
                                <h:outputText escape="false" value="Event&lt;br/&gt;Time"/>
                            </f:facet>
                            <h:outputText value="#{item.eventInfo.startEvent}">
                                <f:convertDateTime pattern="MM/dd/yyyy" />
                            </h:outputText>
                            <h:outputText value=" - " />
                            <h:outputText value="#{item.eventInfo.finishEvent}">
                                <f:convertDateTime pattern="MM/dd/yyyy" />
                            </h:outputText>
                        </p:column>
                        <p:column style="width: 120px;">
                            <f:facet name="header">
                                <h:outputText escape="false" value="Registration&lt;br/&gt;Time"/>
                            </f:facet>
                            <h:outputText value="#{item.regTime}">
                                <f:convertDateTime pattern="MM/dd/yyyy" />
                            </h:outputText>
                        </p:column>
                        <p:column style="width: 120px;" sortBy="#{item.statusReg}">
                            <f:facet name="header">
                                <h:outputText value="Status"/>
                            </f:facet>
                            <h:outputText value="#{item.statusReg}" />
                        </p:column>
                        <p:column style="width: 90px;">
                            <f:facet name="header">
                                <h:outputText value="Action"/>
                            </f:facet>
                            <p:commandButton icon="ui-icon-plusthick" rendered="#{registrationController.today.before(item.eventInfo.startEvent) and item.statusReg eq 'Pending'}"
                                             action="#{registrationController.cancelMyRegistration}"
                                             value="Cancel" ajax="false"/>
                            <h:outputText value="Event has been de-activate !"
                                          rendered="#{item.eventInfo.isDelete}"
                                          style="font-style: oblique;color: red"/>
                        </p:column>
                    </p:dataTable>
                </h:form>

            </ui:define>

        </ui:composition>

    </body>
</html>
